package com.foreknow.elm.controller;

import com.foreknow.elm.po.User;
import com.foreknow.elm.service.impl.UserServiceImpl;

import javax.servlet.http.HttpServletRequest;

public class UserController {
    public User getUserByIdByPass(HttpServletRequest request){
        String userId = request.getParameter("userId");
        String password = request.getParameter("password");
        UserServiceImpl userService = new UserServiceImpl();
        User userByIdByPass = userService.getUserByIdByPass(userId, password);
        return userByIdByPass;
    }
    public User getUserById(HttpServletRequest request){
        String userId = request.getParameter("userId");
        UserServiceImpl userService = new UserServiceImpl();
        User userById = userService.getUserById(userId);
        return userById;
    }
    public Object saveUser(HttpServletRequest request){
        String userId = request.getParameter("userId");
        String password = request.getParameter("password");
        String userName = request.getParameter("userName");
        Integer userSex = Integer.valueOf(request.getParameter("userSex"));
        User user = new User(userId,password,userName,userSex);
        UserServiceImpl userService = new UserServiceImpl();
        int i = userService.saveUser(user);
        return i;
    }
}
